<?php
/**
 * Created by PhpStorm.
 * User: 赵坤
 * Date: 2016/12/14
 * Time: 12:43
 */
namespace app\waterdata\controller;
use app\common\controller\BaseData;
use think\Db;


class Qiniu extends BaseData
{
    public function index(){
        $_body = file_get_contents('php://input');
        $body = json_decode($_body, true);
        $aclass_id=3;//其他
        if(isset($body['img_type'])&&!empty($body['img_type'])){
            if($body['img_type']=='headimg'){
                $aclass_id=1;//头像
            }elseif($body['img_type']=='goodsimg'){
                $aclass_id=2;//商品
            }
        }
        $image = array(
            'apic_name'=>$body['fkey'],
            'apic_tag'=>$body['fname'],
            'aclass_id'=>$aclass_id,
            'apic_cover'=>config('qiniu_bucket_url'),
            'apic_size'=>$body['filesize'],
            'apic_spec'=>'',
            'seller_id'=>$body['uid'],
            'supplier_id'=>0,
            'store_id'=>0,
            'upload_time'=>time()

        );
        Db::name('shop_album_pic')->insert($image);
        $resp = array('ret' => 'success');
        return json($resp);
    }
}